// import { useI18n } from "vue-i18n";
// const { t } = useI18n();


export  const validMobile = (t,message='') => {
    return {
      validator: (_, value, callback) => {
        if (value === '') {
          callback(new Error(message || t('common.txt2')))
        } else {
          const reg = /^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/
          if (!reg.test(value)) {
            callback(new Error(message || t('common.txt2')))
          } else {
            callback()
          }
        }
      },
      trigger: 'blur' 
    }
  }
  
export const validEmail = (t,message='')  => {
  return {
    validator: (_, value, callback) => {
      const reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z]{2,4})+$/
      if (!reg.test(value)) {
        callback(new Error(message || t('common.txt4')))
      } else {
        callback()
      }
    }
  }
}
export   const validPWD = (t,message='') => {
  return {
    validator: (_, value, callback) => {
      if (value === '' || value.length < 6 || value.length > 12) {
        callback(new Error(message || t('common.txt5')))
      } else {
        const reg = /^(?![A-Za-z]+$)(?![.@$!%*#_~?&^]+$)(?!\d+$)[\da-zA-Z.@$!%*#_~?&^]{6,12}$/
        if (!reg.test(value)) {
          callback(new Error(message || t('common.txt5')))
        } else {
          callback()
        }
      }
    }
  }
}

export const validPayPWD = (t,message='') => {
  return {
    validator: (_, value, callback) => {
      if (value === '' || value.length < 6 || value.length > 12) {
        callback(new Error(message || t('modifyNumber.sub7')))
      } else {
        const reg = /^\d{6}$/
        if (!reg.test(value)) {
          callback(new Error(message || t('modifyNumber.sub7')))
        } else {
          callback()
        }
      }
    }
  }
}